const T = getApp().globalData.T
const config = getApp().globalData.config 

function collect(_param) {
    return new Promise((resolve, reject) => {
      T.req({
        loadTitle: '操作中...',
        url: config.api + 'collection?' + T.param(_param),
        method: 'POST',
        success: (res) => {
          resolve(res);
        },
        fail: (fail) => {
          reject(fail);
        }
      })
    })
}
/**
 * 是否已经收藏
 */
function isCollect(id, type) {
  let token = getApp().globalData.token
  return new Promise((resolve, rejct) => {
    T.req({
      url: config.api + 'collection',
      method: 'GET',
      data: {
        token: token,
        id: Number(id),
        type: type,
        userId: getApp().globalData.userId,
        userType: 1
      },
      success: (res) => {
        resolve(res);
      }
    })

  });
}

// export default collect = collect;
module.exports = {
  collect: collect,
  isCollect: isCollect
}